	import mx.containers.Form;
	import mx.containers.FormItem;
	import mx.controls.Alert;
	import mx.controls.ComboBox;
	import mx.controls.Label;
	import mx.events.ValidationResultEvent;
	import mx.managers.PopUpManager;
	import mx.messaging.messages.ErrorMessage;
	import mx.rpc.events.FaultEvent;
	import mx.validators.Validator;
		
	public function getServletURL(type:String): String{
		var s:String=":8080/hotline";
		var query:String = ExternalInterface.call("window.location.href.toString", 1);
		var length:int = query.indexOf(s);
		var url:String="";
		if ("D"==type)
		{
			url="/FileDownloadServlet";
		}else if ("U"==type)
		{
			url="/FileUploadServlet";
		}
		var query1:String=query.substr(0,length+s.length)+url;
		return query1;
	}
		
	public function addMsg(obj:Object,message:String):void{
		obj.text=message;
		obj.visible=true;
		obj.includeInLayout=true;
		obj.setStyle("color","blue");
		obj.setStyle("fontSize",15);	
	}
	
	public function addError(obj:Object,message:String):void{
		obj.text=message;
		obj.visible=true;
		obj.includeInLayout=true;
		obj.setStyle("color","red");
		obj.setStyle("fontSize",15);	
	}
	
	public function clearMsg(obj:Object):void{
		obj.includeInLayout=false;
		obj.text="";
		obj.visible=false;
	
	}

	public function getAlertMsg(msg:String,width:Number):void{
		Alert.okLabel="确定";
   		var alert:Alert=Alert.show(msg,"提示");
   		PopUpManager.centerPopUp(alert);
		alert.width=400;
		alert.height=100;
	}
	
	public function getConfirmAlertMsg(msg:String,title:String,fun:Function):void
	{
		Alert.okLabel="是";
        Alert.noLabel="否";
	
		var alert:Alert=Alert.show(msg,
		title,
		Alert.OK|Alert.NO,
		null,
		fun);
		PopUpManager.centerPopUp(alert);
		alert.width=400;
		alert.height=100;
	}
	
	public function getDefaultAlertMsg(msg:String):void{
		this.getAlertMsg(msg,400);
	}
	public function getFault(event:FaultEvent):void {  
	        var errorMessage:ErrorMessage = event.message as ErrorMessage;
	        if(errorMessage.rootCause.message!=null && errorMessage.rootCause.message!=""){
				getDefaultAlertMsg(errorMessage.rootCause.message);
	        }
	}